import React from 'react';
import { Route, Switch, routerRedux } from 'dva/router';

import dynamic from 'dva/dynamic' // 路由按需加载
import App from './routes/App'


const { ConnectedRouter } = routerRedux

function RouterConfig({ history, app}) {
  const IndexPage = dynamic({
    app,
    component: () => import('./routes/IndexPage')
  })
  const Users = dynamic({
    app,
    component: () => import('./routes/Users')
  })
  return (
    <ConnectedRouter history={history}>
      <App>
        <Switch>
          <Route path="/" exact component={IndexPage} />
          <Route path='/users' exact component={Users} />
        </Switch>
      </App>
    </ConnectedRouter>
  );
}

export default RouterConfig;
